/*
 * Copyright (c) 2015 /3 /29
 * 	      6 :22 : 11
 *               By: wupeiji
 *               Q  Q:757671834
 * 	      It is not easy to meet each other in such a big world
 */

package spring.security.maven.util;

import java.util.Collection;

public class Page {

	private Integer pageNo;    //??????
	private Integer pageSize;  //?????????
	private Boolean nextPage;  //?????????
	private Boolean prePage;   //?????????
	private Integer totalRecNum;  //????ж????????
	private Integer totalPageNum;//????????
	private Collection pageContent; //?????????(??????)
	private Integer startIndex; //??????λ??
	private Integer endIndex;   //???????λ??

	public Page() {
		super();
		pageNo = 1;
		pageSize = 4;
	}

	public Integer getPageNo() {
		return pageNo;
	}

	public void setPageNo(Integer pageNo) {
		this.pageNo = pageNo;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Boolean getNextPage() {
		return pageNo < getTotalPageNum() ? true : false;
	}

	public Boolean getPrePage() {
		return pageNo > 1 ? true : false;
	}

	public Integer getTotalRecNum() {
		return totalRecNum;
	}

	public void setTotalRecNum(Integer totalRecNum) {
		this.totalRecNum = totalRecNum;
	}

	public Integer getTotalPageNum() {
		return totalRecNum % pageSize > 0 ? (int) (totalRecNum / pageSize + 1) : (int) (totalRecNum / pageSize);
	}

	public Collection getPageContent() {
		return pageContent;
	}

	public void setPageContent(Collection pageContent) {
		this.pageContent = pageContent;
	}

	public int getStartIndex() {
		//return pageSize*(pageNo-1)+1;  // size:10 pageno:3   21
		return pageSize * (pageNo - 1);  // size:10 pageno:3   21

	}

	public int getEndIndex() {
		return (pageSize * pageNo > this.totalRecNum) ? (int) (this.totalRecNum.longValue()) : (pageSize * pageNo);
	}
}